/*
 *  cout << expr1 << expr2 << expr3;
 *
 *  expr 的求值顺序一般是 expr3 , expr2 , expr1
 */
#include <iostream>
#include <string>

using namespace std;

string pr_str( const string &identify )
{
	cout << identify << endl;
	return "";
}

int pr_int( const string &identify )
{
	cout << identify << endl;
	return 0;
}

class T {
public:
	T &f( int ) {
		return *this;
	}
};

int main( int argc, char *argv[] )
{
	cout << pr_str( "left" ) << pr_str( "right" ) << endl;
	operator<<( operator<<( cout, pr_str( "left" ) ), pr_str( "right" ) ).operator<<( endl );

	cout << "===============================================" << endl;

	cout << pr_int( "left" ) << pr_int("right") << endl;
	// operator<<( operator<<( cout, pr_int( "left" ) ), pr_int( "right" ) ).operator<<( endl );
	cout.operator<<( pr_int("left") ).operator<<(pr_int( "right" )).operator<<( endl );

	cout << "===============================================" << endl;

	cout << "===============================================" << endl;

	T t;
	t.f( pr_int( "left" ) ).f( pr_int( "right" ) );

	return 0;
}

